<template>
  <div class="settings">
    <van-nav-bar safe-area-inset-top placeholder :title="$t('AdvancedSetting')" left-arrow fixed @click-left="onClickLeft" />
    <van-pull-refresh v-model="isLoading" :pulling-text="$t('PullingText')" :loosing-text="$t('PullingText')" :success-text="$t('refreshSuccee')" @refresh="onRefresh">
      <van-collapse class="marginTop15" v-model="activeNames">
        <van-collapse-item :title="$t('Safety')" name="1">
          <safetyVue :deviceType="6" :safety="safety" :key="timer" @getFormData="setSafety"></safetyVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('PVConnection')" name="2">
          <languageVue :columns="pvConnectArr" :valName="'PvModeValue'" :subOption="'PvMode'" :setValue="LocalArr.PvModeCode"></languageVue>
        </van-collapse-item>
        <van-collapse-item title="Function Setting" name="3">
          <van-form @submit="FuncSetSubmit">
            <van-field :value="arcMode" :label="$t('ARCDetection')" readonly clickable name="picker" input-align="right" @click="showARC = true" />
            <van-popup v-model="showARC" round position="bottom">
              <van-picker show-toolbar :columns="ARCArr" 
                @cancel="showARC = false" 
                @confirm="ARCConfirm" 
                :confirm-button-text="$t('OK')"
                :cancel-button-text="$t('Cancel')"
              />
            </van-popup>
            <van-field :value="shadowMode" label="Shadow MPPT" readonly clickable name="picker" input-align="right" @click="showShadow = true" />
            <van-popup v-model="showShadow" round position="bottom">
              <van-picker show-toolbar :columns="ARCArr" 
                @cancel="showShadow = false"
                @confirm="ShadowConfirm" 
                :confirm-button-text="$t('OK')"
                :cancel-button-text="$t('Cancel')"
               />
            </van-popup>
            <van-field :value="LVRTMode" label="LVRT" readonly clickable name="picker" input-align="right" @click="showLVRT = true" />
            <van-popup v-model="showLVRT" round position="bottom">
              <van-picker show-toolbar :columns="ARCArr" 
                @cancel="showLVRT = false" 
                @confirm="LVRTConfirm" 
                :confirm-button-text="$t('OK')"
                :cancel-button-text="$t('Cancel')"
              />
            </van-popup>
            <van-field :value="NetWorkMode" :label="$t('NetWork')" readonly clickable name="picker" input-align="right" @click="showNetWork = true" />
            <van-popup v-model="showNetWork" round position="bottom">
              <van-picker show-toolbar :columns="NetWorkArr" 
                @cancel="showNetWork = false" 
                @confirm="NetWorkConfirm" 
                :confirm-button-text="$t('OK')"
                :cancel-button-text="$t('Cancel')"
              />
            </van-popup>
            <van-field :value="NeutralMode" label="Neutral to Earth" readonly clickable name="picker" input-align="right" @click="showNeutral = true" />
            <van-popup v-model="showNeutral" round position="bottom">
              <van-picker show-toolbar :columns="ARCArr" 
                @cancel="showNeutral = false"
                @confirm="NeutralConfirm" 
                :confirm-button-text="$t('OK')"
                :cancel-button-text="$t('Cancel')"
               />
            </van-popup>
            <div class="factorBtnBox">
              <van-button block round>{{$t('Save')}}</van-button>
            </div>
          </van-form>
        </van-collapse-item>
        <van-collapse-item :title="$t('PowerFactor')" name="4">
          <van-form @submit="powerfactorSubmit">
            <van-field :value="factMode" :label="$t('ModeSelect')" readonly clickable name="picker" input-align="right" @click="showPowerFact = true" />
            <van-popup v-model="showPowerFact" round position="bottom">
              <van-picker show-toolbar :columns="powerFactors" 
                @cancel="showPowerFact = false" 
                @confirm="factModeConfirm"
                :confirm-button-text="$t('OK')"
                :cancel-button-text="$t('Cancel')"
               />
            </van-popup>
            <van-field v-if="factModeCode==1||factModeCode==2" 
              v-model="P2Value" 
              :label="$t('PFValue')" 
              type="number" 
              show-error 
              name="validator" 
              input-align="right" 
              error-message-align="right" 
              clearable 
              :rules="[{ validator:fixedTwo1,message: `${$t('Range')}：0.80-1.00` }]" 
            />
            <van-field v-if="factModeCode==3"
              v-model="P3Value" 
              :label="$t('UpperLimit')" 
              type="number" 
              show-error 
              name="validator" 
              input-align="right" 
              error-message-align="right" 
              clearable 
              :rules="[{ validator:fixedTwo2,message: `${$t('Range')}：0.90-1.00` }]" 
            />
            <van-field v-if="factModeCode==3"
              v-model="P4Value" 
              :center="$t('LowerLimit')" 
              type="number" 
              show-error 
              name="validator" 
              input-align="right" 
              error-message-align="right" 
              clearable 
              :rules="[{ validator:fixedTwo2,message: `${$t('Range')}：0.90-1.00` }]" 
            />
            <van-field v-if="factModeCode==3"
              v-model="P5Value" 
              :label="$t('PowerLow')" 
              type="number" 
              show-error 
              name="validator" 
              input-align="right" 
              error-message-align="right" 
              clearable 
              :rules="[{ validator:fixedTwo3,message: `${$t('Range')}：0.00-1.00` }]" 
            />
            <van-field v-if="factModeCode==3"
              v-model="P6Value" 
              :label="$t('PowerUp')" 
              type="number" 
              show-error 
              name="validator" 
              input-align="right" 
              error-message-align="right" 
              clearable 
              :rules="[{ validator:fixedTwo3,message: `${$t('Range')}：0.00-1.00` }]" 
            />
            <div class="factorBtnBox">
              <van-button block round>{{$t('Save')}}</van-button>
            </div>
          </van-form>
          <pfLockInPointVue :setName="$t('wQuVrateUp')" :setUntil="'%'" :setMin="100" :setMax="110" :valName="'wQuVrateUpValue'" :subOption="'wQuVrateUp'" :setValue.sync="wQuVrateUpValue" v-if="isQu&&(safety==5||safety==6||safety==7||safety==9||safety==10||safety==14||safety==16)"></pfLockInPointVue>
          <pfLockInPointVue :setName="$t('wQuVrateLow')" :setUntil="'%'" :setMin="90" :setMax="100" :valName="'wQuVrateLowValue'" :subOption="'wQuVrateLow'" :setValue.sync="wQuVrateLowValue" v-if="isQu&&(safety==5||safety==6||safety==7||safety==9||safety==10||safety==14||safety==16)"></pfLockInPointVue>
          <pfLockInPointVue :setName="$t('SetQurangeV1')" :setUntil="'%'" :setMin="0" :setMax="60" :valName="'SetQurangeV1Value'" :subOption="'SetQurangeV1'" :setValue.sync="SetQurangeV1Value" v-if="isQu&&(safety==19||safety==20)"></pfLockInPointVue>
          <pfLockInPointVue :setName="$t('SetQurangeV4')" :setUntil="'%'" :setMin="0" :setMax="60" :valName="'SetQurangeV4Value'" :subOption="'SetQurangeV4'" :setValue.sync="SetQurangeV4Value" v-if="isQu&&(safety==19||safety==20)"></pfLockInPointVue>
          <pfLockInPoint2Vue :setName="$t('bQpower_set')" :setMin="-25000" :setMax="25000" :valName="'bQpower_setValue'" :subOption="'bQpower_set'" :setValue.sync="bQpower_setValue" v-if="isQSet&&(safety==5||safety==6||safety==7||safety==9||safety==16||safety==19||safety==20)"></pfLockInPoint2Vue>
        </van-collapse-item>
        <van-collapse-item :title="$t('Grid')" name="5">
          <vacMaxVue :setName="$t('VacLower')" :setUntil="'V'" :setMin="'1.0'" :setMax="'300.0'" :valName="'VacMinValue'" :subOption="'VacMin'" :setValue.sync="VacMinValue" v-if="safety!=12"></vacMaxVue>
          <vacMaxVue :setName="$t('VacUpper')" :setUntil="'V'" :setMin="'200.0'" :setMax="'400.0'" :valName="'VacMaxValue'" :subOption="'VacMax'" :setValue.sync="VacMaxValue" v-if="safety!=12"></vacMaxVue>
          <facMaxVue :setName="$t('FacLower')" :setUntil="'Hz'" :setMin="'40.00'" :setMax="'70.00'" :valName="'FacMinValue'" :subOption="'FacMin'" :setValue.sync="FacMinValue" v-if="safety!=12"></facMaxVue>
          <facMaxVue :setName="$t('FacUpper')" :setUntil="'Hz'" :setMin="'40.00'" :setMax="'70.00'" :valName="'FacMaxValue'" :subOption="'FacMax'" :setValue.sync="FacMaxValue" v-if="safety!=12"></facMaxVue>
          <vacMaxVue :setName="$t('Vac10MAvg')" :setUntil="'V'" :setMin="'200.0'" :setMax="'400.0'" :valName="'Grid10MinAverageValue'" :subOption="'Grid10MinAverage'" :setValue.sync="Grid10MinAverageValue" v-if="safety==4||safety==5||safety==6||safety==7||safety==8||safety==19||safety==20||safety==23"></vacMaxVue>
          <vacMaxVue :setName="$t('VacLowerSlow')" :setUntil="'V'" :setMin="'100.0'" :setMax="'300.0'" :valName="'VacMinSlowProtectValue'" :subOption="'VacMinSlowProtect'" :setValue.sync="VacMinSlowProtectValue"></vacMaxVue>
          <vacMaxVue :setName="$t('VacUpperSlow')" :setUntil="'V'" :setMin="'200.0'" :setMax="'400.0'" :valName="'VacMaxSlowProtectValue'" :subOption="'VacMaxSlowProtect'" :setValue.sync="VacMaxSlowProtectValue"></vacMaxVue>
          <facMaxVue :setName="$t('FacLowerSlow')" :setUntil="'Hz'" :setMin="'40.00'" :setMax="'70.00'" :valName="'FacMinSlowProtectValue'" :subOption="'FacMinSlowProtect'" :setValue.sync="FacMinSlowProtectValue"></facMaxVue>
          <facMaxVue :setName="$t('FacUpperSlow')" :setUntil="'Hz'" :setMin="'40.00'" :setMax="'70.00'" :valName="'FacMaxSlowProtectValue'" :subOption="'FacMaxSlowProtect'" :setValue.sync="FacMaxSlowProtectValue"></facMaxVue>
          <vacMiddleVue :setName="'VacMiddle_slow_Protect'" :setUntil="'V'" :setMin="'200.0'" :setMax="'400.0'" :subOption="'VacMiddle_slow_Protect'" :setValue.sync="VacMiddleSlowProtectValue" v-if="safety==21"></vacMiddleVue>
          <facMaxVue :setName="$t('wFreqSetPoint')" :setUntil="'Hz'" :setMin="'50.20'" :setMax="'51.00'" :valName="'wFreqSetPointValue'" :subOption="'wFreqSetPoint'" :setValue.sync="wFreqSetPointValue" v-if="safety==5||safety==6||safety==7||safety==8"></facMaxVue>
          <pfLockInPointVue :setName="$t('wFreqDroopRate')" :setUntil="'%'" :setMin="2" :setMax="12" :valName="'wFreqDroopRateValue'" :subOption="'wFreqDroopRate'" :setValue.sync="wFreqDroopRateValue" v-if="safety==5||safety==6||safety==7||safety==8"></pfLockInPointVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('DciLimits')" name="6">
          <pfLockInPointVue :setName="$t('DciLimits')" :setUntil="'mA'" :setMin="20" :setMax="2000" :valName="'DCILimitValue'" :subOption="'DCILimit'" :setValue.sync="DCILimitValue"></pfLockInPointVue>
        </van-collapse-item>
        <van-collapse-item title="SetOFLimit (%)" name="7" v-if="safety==19||safety==20||safety==21">
          <setOFLimitVue :setMin="'20.00'" :setMax="'2000.00'" :subOption="'SetOFLimit'" :setValue.sync="SetOFLimitValue"></setOFLimitVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('puFunction')" name="8" v-if="safety==19||safety==20">
          <enablepublicVue
            :setName="$t('puFunction')"
            :columns="ARCArr"
            :setValue="LocalArr.puFunctionEnableCode"
            :subOption="'puFunction'"
            @getFormData="setPuFunction"
          ></enablepublicVue>
          <vacMaxVue :setName="$t('SetV2')" :setUntil="'V'" :setMin="'216.0'" :setMax="'266.0'" :valName="'SetV2Value'" :setValue.sync="SetV2Value" :subOption="'SetV2'" v-if="isPu"></vacMaxVue>
          <vacMaxVue :setName="$t('SetV3')" :setUntil="'V'" :setMin="'235.0'" :setMax="'295.0'" :valName="'SetV3Value'" :setValue.sync="SetV3Value" :subOption="'SetV3'" v-if="isPu"></vacMaxVue>
          <vacMaxVue :setName="$t('SetV4')" :setUntil="'V'" :setMin="'244.0'" :setMax="'306.0'" :valName="'SetV4Value'" :setValue.sync="SetV4Value" :subOption="'SetV4'" v-if="isPu"></vacMaxVue>
        </van-collapse-item>
        <van-collapse-item title="DRM Function" name="9" v-if="safety==19||safety==20">
          <enablepublicVue :subOption="'wAS4777PowerManagerEnable'" :columns="ARCArr" :setValue="LocalArr.DRMFunctionValue"></enablepublicVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('SetWgra')" name="10" v-if="safety==19||safety==20">
          <facMaxVue :setName="$t('SetWgra')" :setUntil="'%'" :setMin="'0.00'" :setMax="'100.00'" :valName="'SetWgraValue'" :subOption="'SetWgra'" :setValue.sync="SetWgraValue"></facMaxVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('Reset')" name="11">
          <resetINVEnergyVue :setName="$t('ClearInverterHistory')" :valName="'ClearInverterHistoryValue'" :subOption="'ClearInverterHistory'"></resetINVEnergyVue>
          <resetErrorLogsVue :setName="$t('ResetErrorLogs')" :subOption="'ResetErrorLog'"></resetErrorLogsVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('NewPassword')" name="12">
          <newPasswordVue :valName="'NewPasswordValue'" :subOption="'NewPassword'" :setValue.sync="NewPasswordValue"></newPasswordVue>
        </van-collapse-item>
      </van-collapse>
    </van-pull-refresh>
  </div>
</template>

<script>
import safetyVue from '../../../components/Safety/Safety'
import pfLockInPointVue from '../../../components/PfLockInPoint/PfLockInPoint'
import vacMaxVue from '../../../components/VacMax/VacMax'
import enablepublicVue from '../../../components/EnablePublic/EnablePublic'
import facMaxVue from '../../../components/FacMax/FacMax'
import vacMiddleVue from '../../../components/VacMiddle/VacMiddle'
import languageVue from '../../../components/Language/Language'
import resetINVEnergyVue from '../../../components/ResetINVEnergy/ResetINVEnergy'
import resetErrorLogsVue from '../../../components/ResetErrorLogs/ResetErrorLogs'
import newPasswordVue from '../../../components/NewPassword/NewPassword'
import setOFLimitVue from '../../../components/SetOFLimit/SetOFLimit'
import pfLockInPoint2Vue from '../../../components/PfLockInPoint/PfLockInPoint2'

export default {
  components:{
    safetyVue,
    pfLockInPointVue,
    vacMaxVue,
    enablepublicVue,
    facMaxVue,
    vacMiddleVue,
    languageVue,
    resetINVEnergyVue,
    resetErrorLogsVue,
    newPasswordVue,
    setOFLimitVue,
    pfLockInPoint2Vue
  },
  data(){
    return {
      isLoading:false,
      timer:'',
      activeNames:[],
      safety:sessionStorage.getItem('safety'),
      pvConnectArr:[this.$t('Comm'),this.$t('Multi')],
      showARC:false,
      ARCArr:[this.$t('Disable'),this.$t('Enable')],
      arcMode:'',
      arcModeCode:'',
      showShadow:false,
      shadowMode:'',
      shadowModeCode:'',
      showLVRT:false,
      LVRTMode:'',
      LVRTModeCode:'',
      NetWorkArr:['3/N/PE','3/PE'],
      NetWorkMode:'',
      NetWorkModeCode:'',
      showNetWork:false,
      NeutralMode:'',
      NeutralModeCode:'',
      showNeutral:false,
      showPowerFact:false,
      factorArr:[{text:this.$t('Off'),code:0},{text:this.$t('OverExcited'),code:1},{text:this.$t('UnderExcited'),code:2},{text:this.$t('PF(P)'),code:3},{text:this.$t('Q(u)'),code:4},{text:this.$t('Q-Set'),code:5}],
      powerFactors:[],
      factMode:'',
      factModeCode:'',
      isPFP:true,
      isQu:true,
      isQSet:true,
      P2Value:'',
      P3Value:'',
      P4Value:'',
      P5Value:'',
      P6Value:'',
      wQuVrateUpValue:'',
      wQuVrateLowValue:'',
      SetQurangeV1Value:'',
      SetQurangeV4Value:'',
      bQpower_setValue:'',
      VacMinValue:'',
      VacMaxValue:'',
      FacMinValue:'',
      FacMaxValue:'',
      Grid10MinAverageValue:'',
      VacMinSlowProtectValue:'',
      VacMaxSlowProtectValue:'',
      FacMinSlowProtectValue:'',
      FacMaxSlowProtectValue:'',
      VacMiddleSlowProtectValue:'',
      wFreqSetPointValue:'',
      wFreqDroopRateValue:'',
      DCILimitValue:'',
      SetOFLimitValue:'',
      isPu:false,
      SetV2Value:'',
      SetV3Value:'',
      SetV4Value:'',
      SetWgraValue:'',
      NewPasswordValue:'',
      LocalArr:{
        puFunctionEnableCode:'',
        PvModeCode:'',
        DRMFunctionValue:''
      }
    }
  },
  methods: {
    onClickLeft(){
      this.$router.push({path:'/setting'});
    },
    ARCConfirm(value,i){
      this.showARC=false;
      this.arcMode=value;
      this.arcModeCode=i;
    },
    ShadowConfirm(value,i){
      this.showShadow=false;
      this.shadowMode=value;
      this.shadowModeCode=i;
    },
    LVRTConfirm(value,i){
      this.showLVRT=false;
      this.LVRTMode=value;
      this.LVRTModeCode=i;
    },
    NetWorkConfirm(value,i){
      this.showNetWork=false;
      this.NetWorkMode=value;
      this.NetWorkModeCode=i;
    },
    NeutralConfirm(value,i){
      this.showNeutral=false;
      this.NeutralMode=value;
      this.NeutralModeCode=i;
    },
    factModeConfirm(value,i){
      this.showPowerFact=false;
      this.factMode=value.text;
      this.factModeCode=value.code;
    },
    fixedTwo1(val){
      return this.comm.fixedTwo(val,0.8,1);
    },
    fixedTwo2(val){
      return this.comm.fixedTwo(val,0.9,1);
    },
    fixedTwo3(val){
      return this.comm.fixedTwo(val,0,1);
    },
    LineImpedanceConfirm(value,i){
      this.showLineImpedance=false;
      this.lineImpedanceEnableCode=i;
      this.lineImpedanceEnable=value;
    },
    pfreqConfirm(value,i){
      this.showPfreq=false;
      this.pfreqEnableCode=i;
      this.pfreqEnable=value;
    },
    softStartConfirm(value,i){
      this.showSoftStart=false;
      this.softStartEnableCode=i;
      this.softStartEnable=value;
    },
    async getData(){
      this.comm.loadingShow();
      let datas=await this.SETAPI.setGetData(localStorage.getItem('domain'),{'tokenId':localStorage.getItem('tokenId'),'sn':localStorage.getItem('wifiSN')});
      if(datas.result!=null&&datas.result!="tokenId不合法!"){
        let dataArr = JSON.parse(datas.result);
        this.safety=dataArr[4];
        sessionStorage.setItem('safety',this.safety);
        this.LocalArr.PvModeCode=dataArr[5]-1;
        this.arcModeCode=1;
        //数据初始化
        let Hexadecimal=dataArr[126];
        this.NeutralModeCode=parseInt(Hexadecimal/16);
        this.NeutralMode=this.ARCArr[this.NeutralModeCode];
        Hexadecimal=Hexadecimal%16;
        this.NetWorkModeCode=parseInt(Hexadecimal/8);
        this.NetWorkMode=this.NetWorkArr[this.NetWorkModeCode];
        Hexadecimal=Hexadecimal%8;
        this.LVRTModeCode=parseInt(Hexadecimal/4);
        this.LVRTMode=this.ARCArr[this.LVRTModeCode];
        Hexadecimal=Hexadecimal%4;
        this.shadowModeCode=parseInt(Hexadecimal/2);
        this.shadowMode=this.ARCArr[this.shadowModeCode];
        Hexadecimal=Hexadecimal%2;
        this.arcModeCode=parseInt(Hexadecimal/1);
        this.arcMode=this.ARCArr[this.arcModeCode];
        this.factModeCode=dataArr[13];
        this.factMode=this.factorArr[this.factModeCode].text;
        /*判断用户的选择*/
        if(dataArr[13]==3){
          this.isPFP=true;
        }else{
          this.isPFP=false;
        }
        if(dataArr[13]==4){
          this.isQu=true;
        }else{
          this.isQu=false;
        }
        if(dataArr[13]==5){
          this.isQSet=true;
        }else{
          this.isQSet=false;
        }
        this.P2Value=dataArr[14];
        this.P3Value=dataArr[15];
        this.P4Value=dataArr[16];
        this.P5Value=dataArr[17];
        this.P6Value=dataArr[18];
        this.wQuVrateUpValue=dataArr[102];
        this.wQuVrateLowValue=dataArr[103];
        this.SetQurangeV1Value=dataArr[132];
        this.SetQurangeV4Value=dataArr[133];
        this.bQpower_setValue=dataArr[138];
        this.VacMinValue=dataArr[0];
        this.VacMaxValue=dataArr[1];
        this.FacMinValue=dataArr[2];
        this.FacMaxValue=dataArr[3];
        this.Grid10MinAverageValue=dataArr[6];
        this.VacMinSlowProtectValue=dataArr[7];
        this.VacMaxSlowProtectValue=dataArr[8];
        this.FacMinSlowProtectValue=dataArr[9];
        this.FacMaxSlowProtectValue=dataArr[10];
        this.VacMiddleSlowProtectValue=dataArr[137];
        this.wFreqSetPointValue=dataArr[99];
        this.wFreqDroopRateValue=dataArr[100];
        this.DCILimitValue=dataArr[11];
        this.SetOFLimitValue=dataArr[136];
        this.LocalArr.puFunctionEnableCode=dataArr[131];
        /*判断用户的选择*/
        if(this.LocalArr.puFunctionEnableCode==1){
          this.isPu=true;
        }else{
          this.isPu=false;
        }
        this.SetV2Value=dataArr[128];
        this.SetV3Value=dataArr[129];
        this.SetV4Value=dataArr[130];
        this.LocalArr.DRMFunctionValue=dataArr[139];
        this.SetWgraValue=dataArr[127];
        this.NewPasswordValue=this.comm.showPwd(dataArr[104]);
      }else{
        this.comm.tipsShow('InvNoResponse');
      }
    },
    //获取powerfactor列表
    getPowerFactory(){
      if(this.safety==5||this.safety==6||this.safety==7||this.safety==9||this.safety==16||this.safety==19||this.safety==20){
        this.powerFactors=[{text:this.$t('Off'),code:0},{text:this.$t('OverExcited'),code:1},{text:this.$t('UnderExcited'),code:2},{text:this.$t('PF(P)'),code:3},{text:this.$t('Q(u)'),code:4},{text:this.$t('Q-Set'),code:5}];
      }else if(this.safety==10||this.safety==14){
        this.powerFactors=[{text:this.$t('Off'),code:0},{text:this.$t('OverExcited'),code:1},{text:this.$t('UnderExcited'),code:2},{text:this.$t('PF(P)'),code:3},{text:this.$t('Q(u)'),code:4}];
      }else{
        this.powerFactors=[{text:this.$t('Off'),code:0},{text:this.$t('OverExcited'),code:1},{text:this.$t('UnderExcited'),code:2},{text:this.$t('PF(P)'),code:3}];
      }
    },
    //设置安规
    setSafety(data){
      if(data=='success'){
        this.safety=sessionStorage.getItem('safety');
        this.getPowerFactory();
      }
    },
    //设置Function Setting
    FuncSetSubmit(){
      /*数据处理*/
      let formData={
        'Value':Number(this.arcModeCode??0)+(Number(this.shadowModeCode??0))*2+(Number(this.LVRTModeCode??0))*4+(Number(this.NetWorkModeCode??0))*8+(Number(this.NeutralModeCode??0))*16,
        'subOption':'FunctionSelect'
      };
      this.comm.setData('newParaSetting',formData);
    },
    //设置powerfactor
    async powerfactorSubmit(){
      //处理数据
      let factorData_new={};
      factorData_new.optType="PowerFactor";
      factorData_new.sn=localStorage.getItem('wifiSN');
      factorData_new.tokenId=localStorage.getItem('tokenId');
      factorData_new.P1Value=this.factModeCode;
      if(this.P2Value!=null&&this.P2Value!=undefined){
        factorData_new.P2Value=this.comm.mulFunction(this.P2Value,100);
      }
      if(this.P3Value!=null&&this.P3Value!=undefined){
        factorData_new.P3Value=this.comm.mulFunction(this.P3Value,100);
      }
      if(this.P4Value!=null&&this.P4Value!=undefined){
        factorData_new.P4Value=this.comm.mulFunction(this.P4Value,100);
      }
      if(this.P5Value!=null&&this.P5Value!=undefined){
        factorData_new.P5Value=this.comm.mulFunction(this.P5Value,100);
      }
      if(this.P6Value!=null&&this.P6Value!=undefined){
        factorData_new.P6Value=this.comm.mulFunction(this.P6Value,100);
      }
      this.comm.loadingShow();
      let data = await this.SETAPI.setInvMachine(localStorage.getItem('domain'), factorData_new);
      if (data.success) {
        this.comm.toastSuccess();
        /*判断用户的选择*/
        if(this.factModeCode==3){
          this.isPFP=true;
        }else{
          this.isPFP=false;
        }
        if(this.factModeCode==4){
          this.isQu=true;
        }else{
          this.isQu=false;
        }
        if(this.factModeCode==5){
          this.isQSet=true;
        }else{
          this.isQSet=false;
        }
      } else {
        this.comm.toastFail();
      }
    },
    //设置PU Function
    setPuFunction(data){
      /*判断用户的选择*/
      if (data == 1) {
        this.isPu = true;
      } else {
        this.isPu = false;
      }
    },
    onRefresh(){
      this.isLoading = false;
      this.timer=new Date().getTime();
      for(let i in this.LocalArr){
        this.LocalArr[i]='';
      }
      this.getData();
      this.getPowerFactory();
    }
  },
  mounted(){
    this.getData();
    this.getPowerFactory();
  }
}
</script>

<style scoped lang="less">

</style>
